package com.xls.dormitoryservice.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xls.dormitoryservice.entity.Visitor;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author xls
 * @since 2021-03-23
 */
public interface VisitorMapper extends BaseMapper<Visitor> {

    @Select("SELECT\n" +
            "\tid,\n" +
            "\t( SELECT name FROM building WHERE id = building ) AS building,\n" +
            "\tname,\n" +
            "\tphone,\n" +
            "\tvisiting_time AS visitingTime,\n" +
            "\tremarks\n" +
            "FROM\n" +
            "\tvisitor" +
            "\t${ew.customSqlSegment} ORDER BY gmt_modified DESC")
    Page<Visitor> getVisitorPage(Page<Visitor> page, @Param(Constants.WRAPPER) QueryWrapper<Visitor> wrapper);
}
